#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    string str;
    cin >> n >> str;
    int one = 0, zero = 0;
    for (int i = 0; i < str.size(); i++)
    {
        str[i] == '1' ? one++ : zero++;
    }
    int left = 0, right = 0;
    int o = 0, z = 0;;
    while (right < n / 2)
    {
        str[right] == '1' ? o++ : z++;
        right++;
    }
    long long ret = 0;
    while (right < n / 2 + n)
    {
        str[right++ % n] == '1' ? o++ : z++;
        str[left++ % n] == '1' ? o-- : z--;
        if (o * 2 == one && z * 2 == zero) ret++;
    }
    cout << ret << endl;
    return 0;
}